home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / util / gnu / cvs-1.11.1p1.lha / contrib / mfpipe < prev    next >
Encoding:
Text File  |  2001-05-01  |  1.8 KB  |  86 lines

  1. #! /usr/bin/perl
  2. # -*-Perl-*-
  3. #
  4. # From: clyne@niwot.scd.ucar.EDU (John Clyne)
  5. # Date: Fri, 28 Feb 92 09:54:21 MST
  6. # BTW, i wrote a perl script that is similar to 'nfpipe' except that in
  7. # addition to logging to a file it provides a command line option for mailing
  8. # change notices to a group of users. Obviously you probably wouldn't want
  9. # to mail every change. But there may be certain directories that are commonly
  10. # accessed by a group of users who would benefit from an email notice. 
  11. # Especially if they regularly beat on the same directory. Anyway if you 
  12. # think anyone would be interested here it is. 
  13. #
  14. #    File:        mfpipe
  15. #
  16. #    Author:        John Clyne
  17. #            National Center for Atmospheric Research
  18. #            PO 3000, Boulder, Colorado
  19. #
  20. #    Date:        Wed Feb 26 18:34:53 MST 1992
  21. #
  22. #    Description:    Tee standard input to mail a list of users and to
  23. #            a file. Used by CVS logging.
  24. #
  25. #    Usage:        mfpipe [-f file] [user@host...]
  26. #
  27. #    Environment:    CVSROOT    
  28. #                Path to CVS root.
  29. #
  30. #    Files:
  31. #
  32. #
  33. #    Options:    -f file    
  34. #                Capture output to 'file'
  35. #            
  36.  
  37. $header = "Log Message:\n";
  38.  
  39. $mailcmd = "| mail -s  'CVS update notice'";
  40. $whoami = `whoami`;
  41. chop $whoami;
  42. $date = `date`;
  43. chop $date;
  44.  
  45. $cvsroot = $ENV{'CVSROOT'};
  46.  
  47. while (@ARGV) {
  48.         $arg = shift @ARGV;
  49.  
  50.     if ($arg eq '-f') {
  51.                 $file = shift @ARGV;
  52.     }
  53.     else {
  54.         $users = "$users $arg";
  55.     }
  56. }
  57.  
  58. if ($users) {
  59.     $mailcmd = "$mailcmd $users";
  60.     open(MAIL, $mailcmd) || die "Execing $mail: $!\n";
  61. }
  62.  
  63. if ($file) {
  64.     $logfile = "$cvsroot/LOG/$file";
  65.     open(FILE, ">> $logfile") || die "Opening $logfile: $!\n";
  66. }
  67.  
  68. print FILE "$whoami $date--------BEGIN LOG ENTRY-------------\n" if ($logfile);
  69.  
  70. while (<>) {
  71.     print FILE $log if ($log && $logfile);
  72.  
  73.     print FILE $_ if ($logfile);
  74.     print MAIL $_ if ($users);
  75.  
  76.     $log = "log: " if ($_ eq $header);
  77. }
  78.  
  79. close FILE;
  80. die "Write failed" if $?;
  81. close MAIL;
  82. die "Mail failed" if $?;
  83.  
  84. exit 0;
  85.